<!doctype html>
<html xmlns:th="http://www.thymeleaf.org">

<head>
<meta charset="utf-8">
<title>用户中心-上传头像</title>
<link href="../c/base.css" rel="stylesheet" type="text/css">
<link href="../c/toefl.css" rel="stylesheet" type="text/css">
<script src="../j/jquery-2.1.0.js" type="text/javascript"
	charset="utf-8"></script>
<script type="text/javascript" src="../castle/js/castleCreate.js"></script>
<script src="../layer/layer.js" type="text/javascript" charset="utf-8"></script>	
</head>
<script type="text/javascript">
	function addBasic() {
		var msg = "";
		var isCheck = false;
		var isCheckM = false;
		var class_title = $("#class_title").val();
		var start_date = $("#start_date").val();
		var end_date = $("#end_date").val();
		var start_time = $("#start_time").val();
		var end_time = $("#end_time").val();
		var fit_person = $("#fit_person").val();
		var castle_pay = $("#castle_pay").val();
		var castle_cycle = $("[name=castle_cycle]");
		for(var i = 0; i < castle_cycle.length; i++){
			if(castle_cycle[i].checked){
				isCheck = true;
			} 
		}
		var mall_type = $("[name=mall_type]");
		for(var i = 0; i < mall_type.length; i++){
			if(mall_type[i].checked){
				isCheckM = true;
			} 
		}
		if (class_title == "") {
			msg = "课程标题不能为空！";
		} else if (start_date == "") {
			msg = "开始日期不能为空！";
		} else if (end_date == "") {
			msg = "结束日期不能为空！";
		} else if (isCheck == false) {
			msg = "请选择上课周期";
		} else if (start_time == "") {
			msg = "开始时间不能为空！";
		} else if (end_time == "") {
			msg = "结束时间不能为空！";
		} else if (fit_person == "") {
			msg = "适合学员不能为空！";
		} else if (castle_pay == "") {
			msg = "课程费用不能为空！";
		} else if (isCheckM == false) {
			msg = "请选择商城类型！";
		}

		if (msg != "") {
			layer.alert(msg, function(index) {
				layer.close(index);
			});
			return false;
		} else {
			$("#desc").trigger('click');
			return true;
		}
	}

	function addDesc() {
		var msg = "";
		var castle_address = $("#castle_address").val();
		var castle_desc = $("#castle_desc").val();
		var castle_method = $("#castle_method").val();
		 
		if (castle_address == ""){
			msg = "活动地点不能为空！";
		} else if (castle_desc == ""){
			msg = "课程大纲不能为空！";
		}else if (castle_method == ""){
			msg = "上课方式不能为空！";
		}
		
		if (msg != "") {
			layer.alert(msg, function(index) {
				layer.close(index);
			});
			return false;
		} else {
			$("#file").trigger('click');
			return true;
		}
		
	}

	function addAll() {
		var msg = "";
		var isCheck = false;
		var isCheckM = false;
		var class_title = $("#class_title").val();
		var start_date = $("#start_date").val();
		var end_date = $("#end_date").val();
		var start_time = $("#start_time").val();
		var end_time = $("#end_time").val();
		var fit_person = $("#fit_person").val();
		var castle_pay = $("#castle_pay").val();
		var castle_cycle = $("[name=castle_cycle]");
		for(var i = 0; i < castle_cycle.length; i++){
			if(castle_cycle[i].checked){
				isCheck = true;
			} 
		}
		var mall_type = $("[name=mall_type]");
		for(var i = 0; i < mall_type.length; i++){
			if(mall_type[i].checked){
				isCheckM = true;
			} 
		}
		var castle_address = $("#castle_address").val();
		var castle_desc = $("#castle_desc").val();
		var castle_method = $("#castle_method").val();
		
		if (class_title == "") {
			msg = "课程标题不能为空！";
		} else if (start_date == "") {
			msg = "开始日期不能为空！";
		} else if (end_date == "") {
			msg = "结束日期不能为空！";
		} else if (isCheck == false) {
			msg = "请选择上课周期";
		} else if (start_time == "") {
			msg = "开始时间不能为空！";
		} else if (end_time == "") {
			msg = "结束时间不能为空！";
		} else if (fit_person == "") {
			msg = "适合学员不能为空！";
		} else if (castle_pay == "") {
			msg = "课程费用不能为空！";
		} else if (isCheckM == false) {
			msg = "请选择商城类型！";
		} else if (castle_address == ""){
			msg = "活动地点不能为空！";
		} else if (castle_desc == ""){
			msg = "课程大纲不能为空！";
		} else if (castle_method == ""){
			msg = "上课方式不能为空！";
		}
		
		if (msg != "") {
			layer.alert(msg, function(index) {
				layer.close(index);
			});
			return false;
		} else {
			$("#castleform").submit();
			return true;
		}
		
	}

	function addFile() {
		$("#myfile").trigger('click');
	}
</script>

<body>
	<div class="doc910 ">
		<div class="flcb_cardMenu">
			<ul>
				<li class="on"><a href="###" target="infor" id="basic">基本信息</a>
				</li>
				<li><a href="###" target="infor" id="desc">课程描述</a></li>
				<li><a href="###" target="infor" id="file">课程资料</a></li>
			</ul>
		</div>

		<form action="addOrEditCastle" method="post" id="castleform"
			enctype="multipart/form-data">
			<input type="hidden" name="teacher_id"
				th:value="${session.sess_user.teacher_id}"> <input
				type="hidden" name="sort" th:value="${castle.sort}"> <input
				type="hidden" name="castle_id" th:value="${castle.castle_id}">
			<input type="hidden" name="img_url" th:value="${castle.img_url}">

			<div class="userCenter" style="display: block;" id="basicContent">
				<dl>
					<dt>课程标题：</dt>
					<dd>
						<input type="text" class="userCenter_input" name="class_title"
							id="class_title" th:value="${castle.class_title}">
					</dd>
				</dl>
				<dl>
					<dt>开始日期：</dt>
					<dd>
						<input type="date" class="userCenter_input" name="start_date"
							id="start_date"
							th:value="${#dates.format(castle.start_date, 'yyyy-MM-dd')}">
					</dd>
				</dl>
				<dl>
					<dt>结束日期：</dt>
					<dd>
						<input type="date" class="userCenter_input" name="end_date"
							id="end_date"
							th:value="${#dates.format(castle.end_date, 'yyyy-MM-dd')}">
					</dd>
				</dl>
				<dl>
					<dt>上课周期：</dt>
					<dd>
						<div class="userCenter_radio">
							<input name="castle_cycle" type="checkbox" value="1"
								th:checked="${castle.castle_cycle.indexOf('1') >= 0}"><span>周一</span>
							<input name="castle_cycle" type="checkbox" value="2"
								th:checked="${castle.castle_cycle.indexOf('2') >= 0}"><span>周二</span>
							<input name="castle_cycle" type="checkbox" value="3"
								th:checked="${castle.castle_cycle.indexOf('3') >= 0}"><span>周三</span>
							<input name="castle_cycle" type="checkbox" value="4"
								th:checked="${castle.castle_cycle.indexOf('4') >= 0}"><span>周四</span>
							<input name="castle_cycle" type="checkbox" value="5"
								th:checked="${castle.castle_cycle.indexOf('5') >= 0}"><span>周五</span>
							<input name="castle_cycle" type="checkbox" value="6"
								th:checked="${castle.castle_cycle.indexOf('6') >= 0}"><span>周六</span>
							<input name="castle_cycle" type="checkbox" value="7"
								th:checked="${castle.castle_cycle.indexOf('7') >= 0}"><span>周日</span>
						</div>
					</dd>
				</dl>


				<dl>
					<dt>开始时间：</dt>
					<dd>
						<input type="time" class="userCenter_input" name="start_time"
							id="start_time"
							th:value="${#dates.format(castle.start_time, 'HH:mm')}">
					</dd>
				</dl>
				<dl>
					<dt>结束时间：</dt>
					<dd>
						<input type="time" class="userCenter_input" name="end_time"
							id="end_time"
							th:value="${#dates.format(castle.end_time, 'HH:mm')}">
					</dd>
				</dl>

				<dl>
					<dt>适合学员：</dt>
					<dd>
						<input type="text" class="userCenter_input" name="fit_person"
							id="fit_person" th:value="${castle.fit_person}">
					</dd>
				</dl>
				<dl>
					<dt>课程费用：</dt>
					<dd>
						<input type="number" class="userCenter_input" name="castle_pay"
							id="castle_pay" th:value="${castle.castle_pay}">&nbsp;rmb
					</dd>
				</dl>
				<dl>
					<dt>活动分类：</dt>
					<dd>
						<div class="userCenter_radio">
							<input name="mall_type" type="radio"
								th:each="mallType:${mallTypes}" th:value="${mallType.type_id}"
								th:checked="${mallType.type_id == castle.mall_type}"
								th:text="${mallType.type_name}">
						</div>
					</dd>
				</dl>
				<dl>
					<dt>课程分类：</dt>
					<dd>
						<select class="userCenter_input" name="castle_type">
							<option th:each="castleType:${castleTypes}"
								th:value="${castleType.type_id}"
								th:selected="${castle.castle_type == castleType.type_id}">[[${castleType.type_name}]]</option>
						</select>

					</dd>
				</dl>
				<dl>
					<dt>课程阶段：</dt>
					<dd>
						<select class="userCenter_input" name="status">
							<option value="0" th:selected="castle.status == 0">报名阶段</option>
							<option value="1" th:selected="castle.status == 1">结束报名</option>
							<option value="3" th:selected="castle.status == 3">课程结束</option>
						</select>

					</dd>
				</dl>

				<dl>
					<dt></dt>
					<dd>
						<a href="###" class="userCenter_save" onclick="addBasic()">保存</a>
					</dd>
				</dl>
			</div>

			<div class="userCenter" style="display: none;" id="descContent">
				<dl>
					<dt>课程讲师：</dt>
					<dd>
						<input type="text" class="userCenter_input"
							th:value="${session.sess_user.user_name}" readonly>
					</dd>
				</dl>
				<dl>
					<dt>课程群：</dt>
					<dd>
						<select class="userCenter_input" name="group_id">
							<option th:each="group:${groups}" th:value="${group.group_id}" th:selected="${castle.group_id == group.group_id}">[[${group.group_name}]]</option>
						</select>
					</dd>
				</dl>
				<dl>
					<dt>宣传图：</dt>
					<dd>
						<input id="myJpg" name="myJpg" type="file" class="userCenter_input"
							accept="*.jpg,*.png" th:value="${castle.img_url}">

					</dd>
				</dl>

				<dl>
					<dt>活动地点：</dt>
					<dd>
						<input name="castle_address" id="castle_address" type="text" class="userCenter_input"
							th:value="${castle.castle_address}" />

					</dd>
				</dl>
				<dl>
					<dt>课程大纲：</dt>
					<dd>
						<textarea cols="" rows="" class="userCenter_t" name="castle_desc" id="castle_desc">[[${castle.castle_desc}]]</textarea>
						<p class="userCenter_text">请输入2-100个字符</p>
					</dd>
				</dl>
				<dl>
					<dt>上课方式：</dt>
					<dd>
						<textarea cols="" rows="" class="userCenter_t"
							name="castle_method" id="castle_method">[[${castle.castle_method}]]</textarea>
						<p class="userCenter_text">请输入2-100个字符</p>
					</dd>
				</dl>

				<dl>
					<dt></dt>
					<dd>
						<a href="###" class="userCenter_save" onclick="addDesc()">保存</a>
					</dd>
				</dl>
			</div>

			<div class="userTX" style="display: none;" id="fileContent">
				<div class="flcb_cardDownload">
					<h3 class="flcb_cardDownloadT">上传资料信息</h3>
					<ul>
						<li th:each="castleAtta,item:${castleAttas}"><span
							class="flcb_cardDownloadZl">资料[[${item.index + 1}]]</span><span>[[${castleAtta.attachment_name}]]</span>
						</li>
					</ul>
					<div class="flcb_cardUpload">
						<input type="file" id="myfile" name="myfile" style="display: none">
						<a href="###" onclick="addFile()" id="showinfo">上传新资料</a>
					</div>
					<div>
						<a href="###" class="userCenter_save" onclick="addAll()">保存</a>
					</div>
				</div>
			</div>
		</form>

	</div>

</body>

</html>